﻿using System;

class Spiral
{
    static void Main(string[] args)
    {

        int index = 1;
        int colls = 0,
        rows = 0;
        Console.Write("Insert an integer positive number in interval 1...19");

        int n = int.Parse(Console.ReadLine());
        int[,] matrix = new int[n + 1, n + 1];
        for (int i = 0; i < n; i++)
        {
            rows = 0 + i;
            for (colls = 0 + i; colls <= (n - 1 - i); colls++)
            {
                matrix[rows, colls] = index;
                index++;
            }
            colls--; 
           


            for (rows = 1 + i; rows <= n - 1 - i; rows++)
            {
                matrix[rows, colls] = index;
                index++;

            }
            rows--;
            colls--;


            for (colls = n - 2 - i; colls >= i; colls--)
            {

                matrix[rows, colls] = index;
                index++;
            }

            colls++; 
            
            for (rows = n - 2 - i; rows > i; rows--)
            {
                matrix[rows, colls] = index;
                index++;

            }

        }
        Console.WriteLine("\n\n");
        for (int i = 0; i < n; i++)
        {
            for (int j = 0; j < n; j++)
            {
                Console.Write(matrix[i, j] + " ");

            }
            Console.WriteLine("\n");
        }


    }
}

